<?php
/*
	插件概览
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
if($_RQ['op']=='get'){
	//显示统计数据
	$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
	$order['all']=pdo_count('jy_creditshop_log',array('merchid'=>$merchid,'uniacid'=>$_SESSION['uniacid'],'status'=>array(1,2,3,5)));
	$order['day']=pdo_count('jy_creditshop_log',array('merchid'=>$merchid,'uniacid'=>$_SESSION['uniacid'],'status'=>array(1,2,3,5,6),'createtime >'=>$daytime));
	$money['all']=pdo_getsum('jy_creditshop_log',array('merchid'=>$merchid,'uniacid'=>$_SESSION['uniacid'],'status'=>array(1,2,3,5)),'money');
	$money['day']=pdo_getsum('jy_creditshop_log',array('merchid'=>$merchid,'uniacid'=>$_SESSION['uniacid'],'status'=>array(1,2,3,5),'createtime >'=>$daytime),'money');
	$member['day']=pdo_count('jy_merch_member',array('uniacid'=>$_SESSION['uniacid'],'merchid'=>$merchid,'createtime >'=>$daytime));
	$member['all']=pdo_count('jy_merch_member',array('uniacid'=>$_SESSION['uniacid'],'merchid'=>$merchid));
	$jifen['all']=pdo_getsum('jy_creditshop_log',array('merchid'=>$merchid,'uniacid'=>$_SESSION['uniacid'],'status'=>array(1,2,3,5)),'credit');
	$jifen['day']=pdo_getsum('jy_creditshop_log',array('merchid'=>$merchid,'uniacid'=>$_SESSION['uniacid'],'status'=>array(1,2,3,5),'createtime >'=>$daytime),'credit');
	//月份
	for($i=0;$i<12;$i++){
			if($i==0){
				$yuestart = mktime(0,0,0,date('m'),1,date('Y'));
				$yueend = time();
				
			}else{
				$yuestart = mktime(0,0,0,date('m')-$i,1,date('Y'));
				$yueend = mktime(0,0,0,date('m')-$i+1,1,date('Y'));
			}
			$params=array('merchid'=>$merchid,'uniacid'=>$_SESSION['uniacid'],'status'=>array(1,2,3,5));
			$params['createtime between']=array($yuestart,$yueend);
			$month12[] = date('Y-m',strtotime('-'.$i.' month'));
			//$monthaccess[]=pdo_count('core_access_log',$params);
			$monthorder[]=pdo_count('jy_creditshop_log',$params);
			$monthfee=pdo_getsum('jy_creditshop_log',$params,'money');
			$monthmoney[]=intval($monthfee);
			//$monthcredit2[]=pdo_getsum('core_members',$params,'credit2');
	}
	$monthorder=array_reverse($monthorder);
	$monthmoney=array_reverse($monthmoney);
	$month12=array_reverse($month12);
	$htmls=array(
		array('type'=>'data','num'=>12,'one_num'=>3,'title'=>'今日数据/总数据','datas'=>array(
			array('title'=>'总订单数(成功的)','num'=>2,'data'=>array($order['day'],$order['all'])),
			array('title'=>'订单金额(支付的)','yuan'=>1,'num'=>2,'data'=>array($money['day'],$money['all'])),
			array('title'=>'消耗积分','num'=>2,'data'=>array($jifen['day'],$jifen['all'])),
			array('title'=>'总用户','num'=>2,'data'=>array($member['day'],$member['all'])),
		)),
		array('type'=>'echarts_arealine','ecid'=>'mobile','title'=>'月度成交金额','datas'=>array(
					'datas'=>array(
						array('name'=>'成交订单数','value'=>$monthorder),
						array('name'=>'成交订单金额','value'=>$monthmoney),
					),
					'xdatas'=>$month12,
		)),
	);
	$return['htmls']=$htmls;
	exi($return);
}